<?php
/**
 * author: by wzb
 * time:2019/03-01
 * desc:获取本地运单号
 */
require("/home/ryerp_api/magento/Autoloader_d.php");
class Getlocaltracknumber extends Common
{
/**
 * 逻辑是，在抓取单号时，第一次给定状态为0，如果，单号存在，则不在插入和更新该单号的所有信息
 * 在推送单号到magento 时，按照状态为0 推送，如果推送成功 那么创建状态改变为1. 更新修改为2
 * 判断 逻辑 追加 是否出库 满足两个条件，则推送
 * 
 */


public function gettracknumber(){
        $tracknumbers = $this->getTracknumbers();
        $PostTracknumberToMangento = new PostTracknumberToMangento();
        foreach ($tracknumbers as $key => $value) {
            $shopid = 'mall00'.$value['store_id'];//店铺id
            $ShipperCode = $value['ShipperCode'];//物流公司
            $orderid = $value['increment_id'];//订单号
            $trackingnumber = $value['trackingnumber'];//运单号
            $shipmentid = $value['shipmentid'];//运单号id
            $magentoOrderid = $value['orderid'];//单号id
            if (empty($trackingnumber) || $trackingnumber == '') {
                echo $orderid."跳过\n";
                continue;
            }
            echo "$shopid----$ShipperCode------- $orderid-----$trackingnumber------ $shipmentid\n";
            $storeinfo = $this->byStoreIdgetStoreInfo($shopid);
            //发送信息到推送接口
            $PostTracknumberToMangento->PostData($shopid,$trackingnumber,$ShipperCode,$orderid,$shipmentid,$storeinfo,$magentoOrderid);
}

}
	
}
$Getlocaltracknumber = new Getlocaltracknumber();
$Getlocaltracknumber->gettracknumber();
